//package cn.mediinfo.dianzidp.service;
//
//import cn.hutool.core.util.StrUtil;
//import cn.mediinfo.cyan.msf.core.exception.CanShuException;
//import cn.mediinfo.cyan.msf.core.exception.RuntimeException;
//import cn.mediinfo.cyan.msf.core.response.MsfResponse;
//import cn.mediinfo.cyan.msf.core.util.CollectionUtil;
//import cn.mediinfo.cyan.msf.core.util.DateUtil;
//import cn.mediinfo.cyan.msf.stringgenerator.StringGenerator;
//import cn.mediinfo.lyra.extension.service.LyraCanShuService;
//import cn.mediinfo.lyra.extension.service.LyraIdentityService;
//import cn.mediinfo.lyra.jiaohu.provider.annotation.ReceiveHandler;
//import cn.mediinfo.lyra.jiaohu.provider.dtos.Options;
//import cn.mediinfo.lyra.jiaohu.provider.handlers.SenderHandler;
//import cn.mediinfo.vela.jiaohu.dianzidp.builder.JianYanLEDBuilder;
//import cn.mediinfo.vela.jiaohu.dianzidp.builder.PaiBanXXLEDBuilder;
//import cn.mediinfo.vela.jiaohu.dianzidp.builder.YaoFangLEDBuilder;
//import cn.mediinfo.vela.jiaohu.dianzidp.common.dto.JZ_GH_JinRiHYListDto;
//import cn.mediinfo.vela.jiaohu.dianzidp.common.dto.JianYanPinDto;
//import cn.mediinfo.vela.jiaohu.dianzidp.common.dto.YaoPinLEDXXDto;
//import cn.mediinfo.vela.jiaohu.dianzidp.common.service.DianZiDPService;
//import cn.mediinfo.vela.jiaohu.dianzidp.dto.PaiBanKSXXDto;
//import cn.mediinfo.vela.jiaohu.dianzidp.dto.YaoFangChuangKouXXDto;
//import cn.mediinfo.vela.jiaohu.dianzidp.dto.YaoFangXXDto;
//import cn.mediinfo.vela.jiaohu.dianzidp.option.DianZiDPSZOption;
//import jakarta.xml.bind.JAXBException;
//import org.springframework.stereotype.Service;
//
//import java.io.IOException;
//import java.io.UnsupportedEncodingException;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//
//@Service
//public class ShengZhouServiceImpl {
//
////    private final LyraIdentityService lyraIdentityService;
////    private final StringGenerator stringGenerator;
////    private final LyraCanShuService lyraCanShuService;
////    private final PaiBanXXLEDBuilder paiBanXXLEDBuilder;
////    private final YaoFangLEDBuilder yaoFangLEDBuilder;
////    private final JianYanLEDBuilder jianYanLEDBuilder;
//
////    @Override
////    public Options options() {
////        return DianZiDPSZOption.options;
////    }
////
////    public ShengZhouServiceImpl(LyraIdentityService lyraIdentityService,
////                                StringGenerator stringGenerator,
////                                LyraCanShuService lyraCanShuService,
////                                SenderHandler senderHandler, PaiBanXXLEDBuilder paiBanXXLEDBuilder, YaoFangLEDBuilder yaoFangLEDBuilder, JianYanLEDBuilder jianYanLEDBuilder) {
////        this.lyraIdentityService = lyraIdentityService;
////        this.stringGenerator = stringGenerator;
////        this.lyraCanShuService = lyraCanShuService;
////        this.paiBanXXLEDBuilder = paiBanXXLEDBuilder;
////        this.yaoFangLEDBuilder = yaoFangLEDBuilder;
////        this.jianYanLEDBuilder = jianYanLEDBuilder;
////        senderHandler.setOptions(DianZiDPSZOption.options);
////    }
////
////    @Override
////    @ReceiveHandler(xiTongDM = DianZiDPSZOption.xiTongDM,xiTongBB = DianZiDPSZOption.xiTongBB)
////    public MsfResponse<Boolean> sendYiZhouPaiBanXX(List<JZ_GH_JinRiHYListDto> paiBanXX) throws RuntimeException, IOException, JAXBException, UnsupportedEncodingException, CanShuException {
////        List<PaiBanKSXXDto> paiBanKSXXDtos = new ArrayList<>();
////        for (JZ_GH_JinRiHYListDto banXX : paiBanXX) {
////            paiBanKSXXDtos.add(zhuanHuaHYXX(banXX));
////        }
////        /**
////         * 具体的发送代码
////         */
////        paiBanXXLEDBuilder.wf_send_dp2_fp(paiBanKSXXDtos);
////        return MsfResponse.success(true);
////    }
////
////    @Override
////    @ReceiveHandler(xiTongDM = DianZiDPSZOption.xiTongDM,xiTongBB = DianZiDPSZOption.xiTongBB)
////    public MsfResponse<Boolean> sendJinRiPaiBanXX(List<JZ_GH_JinRiHYListDto> paiBanXX) throws RuntimeException, IOException, JAXBException, UnsupportedEncodingException, CanShuException {
////        List<PaiBanKSXXDto> paiBanKSXXDtos = new ArrayList<>();
////        if (CollectionUtil.isEmpty(paiBanXX)){
////            return MsfResponse.success(true);
////        }
////        for (JZ_GH_JinRiHYListDto banXX : paiBanXX) {
////            paiBanKSXXDtos.add(zhuanHuaHYXX(banXX));
////        }
////        /**
////         * 具体的发送代码
////         */
////        paiBanXXLEDBuilder.wf_send_dp1_fp(paiBanKSXXDtos);
////        return MsfResponse.success(true);
////    }
//
////    private PaiBanKSXXDto zhuanHuaHYXX(JZ_GH_JinRiHYListDto banXX) {
////        PaiBanKSXXDto paiBanKSXXDto = new PaiBanKSXXDto();
////        paiBanKSXXDto.setYiShengXM(banXX.getYiShengXM());
////        paiBanKSXXDto.setRiqi(DateUtil.getYYMMDD(banXX.getRiQi()));
////        String shengYuHaoYuan;
////        if (banXX.getZuiGaoXH() != null && banXX.getZuiGaoXH().equals(9999)) {
////            //如果是不限号的情况下 默认300个号源
////            shengYuHaoYuan = "剩余" + (300 - banXX.getYiGuaHSL()) + "号";
////        } else if (banXX.getXianHao() !=null && banXX.getXianHao() - banXX.getYiGuaHSL() > 0) {
////            shengYuHaoYuan = "剩余" + (banXX.getXianHao() - banXX.getYiGuaHSL()) + "号";
////        } else if (banXX.getZuiGaoXH() != null  && banXX.getZuiGaoXH().equals(0) && banXX.getXianHao().equals(0)) {
////            //停诊判断标志 最高序号为0  并且 限号为 0
////            shengYuHaoYuan = "停诊";
////        } else {
////            shengYuHaoYuan = "剩余0号";
////        }
////        paiBanKSXXDto.setShengYuHaoYuan(shengYuHaoYuan);
////        paiBanKSXXDto.setKeShiMC(banXX.getKeShiMC());
////        paiBanKSXXDto.setGuaHaoLB(banXX.getGuaHaoLBMC());
////        paiBanKSXXDto.setShangXiaWu(banXX.getShiDuanMC());
////        return paiBanKSXXDto;
////    }
//
//
////    @Override
////    @ReceiveHandler(xiTongDM = DianZiDPSZOption.xiTongDM,xiTongBB = DianZiDPSZOption.xiTongBB)
////    public MsfResponse<Boolean> sendYaoPinChuangKouXX(List<YaoPinLEDXXDto> chuangKouXXData) throws RuntimeException, ParseException {
////        YaoFangXXDto yaoFangXXDto = new YaoFangXXDto();
////        /**
////         * 此程序设计中窗口号 均为固定值
////         */
////        final String chuangkouxx_00 = "2463045586518020096";         //中药房
////        final String chuangkouxx_01 = "1055522380597723136";         //西药房01
////        final String chuangkouxx_02 = "1069590644789379072";         //西药房02
////        final String chuangkouxx_03 = "1104398042796163072";         //西药房03
////        final String chuangkouxx_04 = "1073214111124324352";         //西药房04
////        final String chuangkouxx_05 = "2447705427475959808";         //西药房05
////
////        Map<String, List<YaoFangChuangKouXXDto>> chuangKouXX = chuangKouXXData.stream()
////                .filter(x -> StrUtil.isNotBlank(x.getChuangKouID()))
////                .map(x -> new YaoFangChuangKouXXDto(x.getChuangKouID(), x.getXingMing()))
////                .collect(Collectors.groupingBy(YaoFangChuangKouXXDto::getChuangKouId));
////        yaoFangXXDto.setChuangkouxx_00(chuangKouXX.get(chuangkouxx_00));
////        yaoFangXXDto.setChuangkouxx_01(chuangKouXX.get(chuangkouxx_01));
////        yaoFangXXDto.setChuangkouxx_02(chuangKouXX.get(chuangkouxx_02));
////        yaoFangXXDto.setChuangkouxx_03(chuangKouXX.get(chuangkouxx_03));
////        yaoFangXXDto.setChuangkouxx_04(chuangKouXX.get(chuangkouxx_04));
////        yaoFangXXDto.setChuangkouxx_05(chuangKouXX.get(chuangkouxx_05));
////
////        /**
////         * 药房两个屏幕的数据发送
////         */
////        yaoFangLEDBuilder.wf_send_dp1(yaoFangXXDto);
////        yaoFangLEDBuilder.wf_send_dp2(yaoFangXXDto);
////        return MsfResponse.success(true);
////    }
//
////    /**
////     * 此处只需要处理展示即可
////     *
////     * @param chuangKouXXData
////     * @param jiGouId
////     * @return
////     */
////    @Override
////    @ReceiveHandler(xiTongDM = DianZiDPSZOption.xiTongDM,xiTongBB = DianZiDPSZOption.xiTongBB)
////    public MsfResponse<Boolean> sendJianYanChuangKouXX(List<JianYanPinDto> chuangKouXXData, String jiGouId) throws RuntimeException,ParseException{
////        //一般来说一个串口只会有一个窗口XXData
////        Map<String, List<JianYanPinDto>> jianYanPing = chuangKouXXData.stream().filter(x -> StrUtil.isNotBlank(x.getChuangKouId()))
////                .collect(Collectors.groupingBy(JianYanPinDto::getChuangKouId));
////        Map<String, JianYanPinDto> jianYanPings = new HashMap<>();
////        jianYanPing.forEach((k,v)->{
////            if (v!=null && !v.isEmpty()){
////                jianYanPings.put(k,v.get(0));
////            }
////        });
////        return jianYanLEDBuilder.jy_ping_send(jianYanPings);
////    }
//
//
//}
